//
//  HomeViewArtGalleryCell.m
//  jingdongfang
//
//  Created by MTiMac01 on 2017/8/18.
//  Copyright © 2017年 LJL. All rights reserved.
//

#import "HomeViewArtGalleryCell.h"

@interface HomeViewArtGalleryCell ()
{
    UIImageView *imgView;
    UIImageView *tras;
    UILabel *name;
    UILabel *zuopin;
}
@end

@implementation HomeViewArtGalleryCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.backgroundColor = [UIColor c2Color];
        [self loadUI];
    }
    return self;
}

- (void)loadUI
{
    imgView = [[UIImageView alloc] initWithFrame:CGRectZero];
    imgView.backgroundColor = [UIColor c2Color];
    imgView.contentMode = UIViewContentModeScaleAspectFill;
    imgView.layer.cornerRadius = 10;
    imgView.layer.masksToBounds = YES;
    [self.contentView addSubview:imgView];
    
    tras = [[UIImageView alloc] initWithFrame:CGRectZero];
    tras.layer.cornerRadius = 10;
    tras.layer.masksToBounds = YES;
    UIImage *image = [UIImage imageNamed:@"B-16-2"];
    [image stretchableImageWithLeftCapWidth:4 topCapHeight:2];
    tras.image = image;
    [self.contentView addSubview:tras];
    
    name = [[UILabel alloc] initWithFrame:CGRectZero];
    name.textColor = [UIColor c3Color];
    name.textAlignment = NSTextAlignmentLeft;
    name.font = [UIFont boldSystemFontOfSize:18];
    [tras addSubview:name];
    
    zuopin = [[UILabel alloc] initWithFrame:CGRectZero];
    zuopin.textColor = [UIColor c3Color];
    zuopin.textAlignment = NSTextAlignmentRight;
    zuopin.font = [UIFont systemFontOfSize:14];
    [tras addSubview:zuopin];
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    [imgView sd_setImageWithURL:[NSURL URLWithString:_museum.museumImage]];
    imgView.frame = CGRectMake(10, 0, self.width - 20, self.height);
    
    tras.frame = CGRectMake(10, 0, self.width - 20, 40);
    tras.bottom = imgView.bottom;
    
    name.text = _museum.museumNm;
    name.frame = CGRectMake(15, 0, 150, 40);

//    zuopin.text = [NSString stringWithFormat:@"%@个作品", _museum.museumProductNum];
    zuopin.text = [NSString stringWithFormat:@"%@ %@", _museum.museumProductNum,NSLocalizedString(@"Pieces of Works", nil)];

//    zuopin.frame = CGRectMake(tras.width - 135, 0, 120, 40);
    zuopin.frame = CGRectMake(CGRectGetMaxX(name.frame), 0, self.width - CGRectGetMaxX(name.frame) - 35, 40);
}

@end
